package exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("开始");
        try {
           // String line = null;
            String line="abc";
            System.out.println(line.length());
            System.out.println(line.charAt(0));
            System.out.println(Integer.parseInt(line));
            System.out.println("gsdfhgiksdhlkisjfl");
        /*} catch (NullPointerException e) {

            System.out.println("解决空指针异常");
        }catch (StringIndexOutOfBoundsException e){
            System.out.println("出现了下标越界这里把他解决了");
        }*/


        }catch (NullPointerException|StringIndexOutOfBoundsException e){//子类异常 在上
            System.out.println("出现空指针异常或下标越界异常处理方式");
    }catch (Exception e){//超类异常 在下
            System.out.println("对不起，这里有一处错误哈哈哈哈笑死");
        }
        System.out.println("结束");
}
}
